<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

   <!-- 百度联盟 -->
   <meta name="baidu_union_verify" content="46e227ad81d5513c6cd8288c18c6ebad">

   <!-- google analytics -->
   <meta name="google-site-verification" content="SzCGQVmA8Mtk40elee-bCGpq2YSCAmEulSNEZHYCkFc" />

   <!--百度站长之家验证-->
   <meta name="baidu-site-verification" content="4woRik4rfk" />

   <meta name="description" content="坑要一个个填，路要一步步走！—— from zhisheng的博客">
   <meta name="keywords" content="Java,架构,后端,服务端,RocketMQ,分布式消息队列,分布式存储,技术博客,HBase,ElasticSearch,Spring,Spring Boot,Spring Boot 2.0,Spring Cloud,Spring MVC,Java EE,前端,HTML,MyBatis,Android,Docker,Mac,Consul,Kafka,Logstash,Kibana,MySQL,Maven,Nginx,Python,RabbitMQ,ActiveMQ,JVM">


  <title>Spring Boot 2.0系列文章(一)：Spring Boot 2.0 迁移指南 | zhisheng的博客</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="前提希望本文档将帮助您把应用程序迁移到 Spring Boot 2.0。">
<meta name="keywords" content="Java,SpringBoot">
<meta property="og:type" content="article">
<meta property="og:title" content="Spring Boot 2.0系列文章(一)：Spring Boot 2.0 迁移指南">
<meta property="og:url" content="http://www.54tianzhisheng.cn/2018/03/06/SpringBoot2-Migration-Guide/index.html">
<meta property="og:site_name" content="zhisheng的博客">
<meta property="og:description" content="前提希望本文档将帮助您把应用程序迁移到 Spring Boot 2.0。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://ws4.sinaimg.cn/large/006tNc79gy1fp3h0820m2j31hc0zkwxr.jpg">
<meta property="og:image" content="http://image.54tianzhisheng.cn/blog/180103/C6LG3mGa12.jpg">
<meta property="og:updated_time" content="2018-11-22T14:51:58.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Spring Boot 2.0系列文章(一)：Spring Boot 2.0 迁移指南">
<meta name="twitter:description" content="前提希望本文档将帮助您把应用程序迁移到 Spring Boot 2.0。">
<meta name="twitter:image" content="https://ws4.sinaimg.cn/large/006tNc79gy1fp3h0820m2j31hc0zkwxr.jpg">
  
    <link rel="alternative" href="/atom.xml" title="zhisheng的博客" type="application/atom+xml">
  
  
    <link rel="icon" href="/img/favicon.ico">
  
  
      <link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.5.0/animate.min.css">
  
  <link rel="stylesheet" href="/css/style.css">
  <link rel="stylesheet" href="/font-awesome/css/font-awesome.min.css">
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">
  
  
      <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  
  <!-- 加载特效 -->
  <script src="/js/pace.js"></script>
  <link href="/css/pace/pace-theme-flash.css" rel="stylesheet" />
  <script>
      var yiliaConfig = {
          rootUrl: '/',
          fancybox: true,
          animate: true,
          isHome: false,
          isPost: true,
          isArchive: false,
          isTag: false,
          isCategory: false,
          open_in_new: true
      }
  </script>
</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            
            <img lazy-src="/img/avatar.png" class="js-avatar">
            
        </a>

        <hgroup>
          <h1 class="header-author"><a href="/">zhisheng</a></h1>
        </hgroup>

        
        <p class="header-subtitle">坑要一个个填，路要一步步走！</p>
        
        
        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>菜单</li>
                        <li>标签</li>
                        
                        <li>友情链接</li>
                        
                        
                        <li>关于我</li>
                        
                    </ul>
                </div>
            </div>
        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">主页</a></li>
                        
                            <li><a href="/tags/Flink/">Flink</a></li>
                        
                            <li><a href="/tags/ElasticSearch/">ElasticSearch</a></li>
                        
                            <li><a href="/tags/SpringBoot/">Spring Boot</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fl wechat" target="_blank" href="wechat:zhisheng_tian" title="wechat">wechat</a>
                            
                                <a class="fl mail" target="_blank" href="mailto://zhisheng2018@gmail.com" title="mail">mail</a>
                            
                                <a class="fl github" target="_blank" href="https://github.com/zhisheng17/" title="github">github</a>
                            
                                <a class="fl zhihu" target="_blank" href="https://www.zhihu.com/people/tian-zhisheng/activities" title="zhihu">zhihu</a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        <a href="/tags/AJAX/" style="font-size: 10px;">AJAX</a> <a href="/tags/ActiveMQ/" style="font-size: 10px;">ActiveMQ</a> <a href="/tags/Android/" style="font-size: 10px;">Android</a> <a href="/tags/Bootstrap/" style="font-size: 13px;">Bootstrap</a> <a href="/tags/Consul/" style="font-size: 10px;">Consul</a> <a href="/tags/Docker/" style="font-size: 11px;">Docker</a> <a href="/tags/ElasticSearch/" style="font-size: 17px;">ElasticSearch</a> <a href="/tags/Filter过滤器/" style="font-size: 10px;">Filter过滤器</a> <a href="/tags/Flink/" style="font-size: 18px;">Flink</a> <a href="/tags/GO/" style="font-size: 10px;">GO</a> <a href="/tags/Github-Page/" style="font-size: 10px;">Github Page</a> <a href="/tags/Guava/" style="font-size: 10px;">Guava</a> <a href="/tags/HBase/" style="font-size: 10px;">HBase</a> <a href="/tags/Hibernate-JPA/" style="font-size: 11px;">Hibernate JPA</a> <a href="/tags/IO/" style="font-size: 11px;">IO</a> <a href="/tags/JMM/" style="font-size: 10px;">JMM</a> <a href="/tags/JSON/" style="font-size: 10px;">JSON</a> <a href="/tags/JVM/" style="font-size: 11px;">JVM</a> <a href="/tags/Java/" style="font-size: 20px;">Java</a> <a href="/tags/Kafka/" style="font-size: 12px;">Kafka</a> <a href="/tags/Kibana/" style="font-size: 10px;">Kibana</a> <a href="/tags/LogStash/" style="font-size: 10px;">LogStash</a> <a href="/tags/Mac/" style="font-size: 10px;">Mac</a> <a href="/tags/Maven/" style="font-size: 11px;">Maven</a> <a href="/tags/MySQL/" style="font-size: 12px;">MySQL</a> <a href="/tags/Mybatis/" style="font-size: 14px;">Mybatis</a> <a href="/tags/NIO/" style="font-size: 10px;">NIO</a> <a href="/tags/Netty/" style="font-size: 10px;">Netty</a> <a href="/tags/Nginx/" style="font-size: 11px;">Nginx</a> <a href="/tags/Oracle/" style="font-size: 10px;">Oracle</a> <a href="/tags/Pyspider/" style="font-size: 10px;">Pyspider</a> <a href="/tags/Python/" style="font-size: 12px;">Python</a> <a href="/tags/RabbitMQ/" style="font-size: 11px;">RabbitMQ</a> <a href="/tags/Redis/" style="font-size: 11px;">Redis</a> <a href="/tags/RocketMQ/" style="font-size: 13px;">RocketMQ</a> <a href="/tags/Servlet/" style="font-size: 10px;">Servlet</a> <a href="/tags/Spring/" style="font-size: 12px;">Spring</a> <a href="/tags/Spring-MVC/" style="font-size: 15px;">Spring MVC</a> <a href="/tags/SpringBoot/" style="font-size: 19px;">SpringBoot</a> <a href="/tags/SpringCloud/" style="font-size: 10px;">SpringCloud</a> <a href="/tags/SpringMVC/" style="font-size: 13px;">SpringMVC</a> <a href="/tags/String/" style="font-size: 10px;">String</a> <a href="/tags/Velocity/" style="font-size: 10px;">Velocity</a> <a href="/tags/Zookeeper/" style="font-size: 10px;">Zookeeper</a> <a href="/tags/finally/" style="font-size: 10px;">finally</a> <a href="/tags/foreach/" style="font-size: 10px;">foreach</a> <a href="/tags/hexo/" style="font-size: 12px;">hexo</a> <a href="/tags/lombok/" style="font-size: 10px;">lombok</a> <a href="/tags/lua/" style="font-size: 10px;">lua</a> <a href="/tags/yilia/" style="font-size: 11px;">yilia</a> <a href="/tags/书籍/" style="font-size: 10px;">书籍</a> <a href="/tags/分布式锁/" style="font-size: 10px;">分布式锁</a> <a href="/tags/前端/" style="font-size: 12px;">前端</a> <a href="/tags/励志/" style="font-size: 10px;">励志</a> <a href="/tags/博客合集/" style="font-size: 10px;">博客合集</a> <a href="/tags/博客网站/" style="font-size: 10px;">博客网站</a> <a href="/tags/多线程/" style="font-size: 11px;">多线程</a> <a href="/tags/大数据/" style="font-size: 18px;">大数据</a> <a href="/tags/字符串/" style="font-size: 11px;">字符串</a> <a href="/tags/实习圈/" style="font-size: 10px;">实习圈</a> <a href="/tags/循环队列/" style="font-size: 10px;">循环队列</a> <a href="/tags/微服务/" style="font-size: 11px;">微服务</a> <a href="/tags/性能调优工具/" style="font-size: 10px;">性能调优工具</a> <a href="/tags/投资理财/" style="font-size: 10px;">投资理财</a> <a href="/tags/数据库/" style="font-size: 12px;">数据库</a> <a href="/tags/数据结构/" style="font-size: 13px;">数据结构</a> <a href="/tags/文件/" style="font-size: 10px;">文件</a> <a href="/tags/旋转词/" style="font-size: 10px;">旋转词</a> <a href="/tags/流式计算/" style="font-size: 18px;">流式计算</a> <a href="/tags/流控/" style="font-size: 10px;">流控</a> <a href="/tags/爬虫/" style="font-size: 12px;">爬虫</a> <a href="/tags/算法/" style="font-size: 12px;">算法</a> <a href="/tags/类加载机制/" style="font-size: 10px;">类加载机制</a> <a href="/tags/线程池/" style="font-size: 10px;">线程池</a> <a href="/tags/编码/" style="font-size: 10px;">编码</a> <a href="/tags/表达式/" style="font-size: 10px;">表达式</a> <a href="/tags/邮件发送/" style="font-size: 10px;">邮件发送</a> <a href="/tags/随笔/" style="font-size: 16px;">随笔</a> <a href="/tags/面经/" style="font-size: 16px;">面经</a>
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://blog.csdn.net/tzs_1041218129">CSDN博客</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="https://juejin.im/user/57510b82128fe10056ca70fc">掘金</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.iocoder.cn/?vip">芋道源码</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://fengzhaofeng.net/">冯兆峯</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.codedata.cn/">CodeData</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="https://investguider.com/">美股指南</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.songyawei.cn/">Linux运维工程师</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.carlzone.cn/">carl.zhao</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://dongkelun.com/">伦少的博客</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.jiangxinlingdu.com/">匠心零度</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">17.08 ~ 18.05 永辉云创基础架构组实习     2018.06 大学毕业   2018.06 ～ 现在  另一家公司各种折腾!</div>
                </section>
                
            </div>
        </div>
        <div>
            <img src="/img/wx.jpg"  alt="zhisheng" />
        </div>
    </header>
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="Me">zhisheng</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                
                    <img lazy-src="/img/avatar.png" class="js-avatar">
                
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="Me">zhisheng</a></h1>
            </hgroup>
            
            <p class="header-subtitle">坑要一个个填，路要一步步走！</p>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">主页</a></li>
                
                    <li><a href="/tags/Flink/">Flink</a></li>
                
                    <li><a href="/tags/ElasticSearch/">ElasticSearch</a></li>
                
                    <li><a href="/tags/SpringBoot/">Spring Boot</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                <div class="social">
                    
                        <a class="wechat" target="_blank" href="wechat:zhisheng_tian" title="wechat">wechat</a>
                    
                        <a class="mail" target="_blank" href="mailto://zhisheng2018@gmail.com" title="mail">mail</a>
                    
                        <a class="github" target="_blank" href="https://github.com/zhisheng17/" title="github">github</a>
                    
                        <a class="zhihu" target="_blank" href="https://www.zhihu.com/people/tian-zhisheng/activities" title="zhihu">zhihu</a>
                    
                </div>
            </nav>
        </header>                
    </div>
</nav>
      <div class="body-wrap"><article id="post-SpringBoot2-Migration-Guide" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2018/03/06/SpringBoot2-Migration-Guide/" class="article-date">
      <time datetime="2018-03-05T16:00:00.000Z" itemprop="datePublished">2018-03-06</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      Spring Boot 2.0系列文章(一)：Spring Boot 2.0 迁移指南
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        

        
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Java/">Java</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/SpringBoot/">SpringBoot</a></li></ul>
    </div>

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <p><img src="https://ws4.sinaimg.cn/large/006tNc79gy1fp3h0820m2j31hc0zkwxr.jpg" alt=""></p>
<h3 id="前提"><a href="#前提" class="headerlink" title="前提"></a>前提</h3><p>希望本文档将帮助您把应用程序迁移到 Spring Boot 2.0。</p>
<a id="more"></a>
<h3 id="关注我"><a href="#关注我" class="headerlink" title="关注我"></a>关注我</h3><p><img src="http://image.54tianzhisheng.cn/blog/180103/C6LG3mGa12.jpg" alt="mark"></p>
<p>转载请务必注明原创地址为：<a href="http://www.54tianzhisheng.cn/2018/03/06/SpringBoot2-Migration-Guide/">http://www.54tianzhisheng.cn/2018/03/06/SpringBoot2-Migration-Guide/</a></p>
<h3 id="在你开始之前"><a href="#在你开始之前" class="headerlink" title="在你开始之前"></a>在你开始之前</h3><p>首先，<strong>Spring Boot 2.0 需要 Java 8 或更高版本</strong>。不再支持 Java 6 和 7 了。</p>
<p>在 Spring Boot 2.0 中，许多配置属性被重新命名/删除，开发人员需要更新<code>application.properties</code>/ <code>application.yml</code>相应的配置。为了帮助你解决这一问题，Spring Boot 发布了一个新<code>spring-boot-properties-migrator</code>模块。一旦作为该模块作为依赖被添加到你的项目中，它不仅会分析应用程序的环境，而且还会在启动时打印诊断信息，而且还会在运行时为您暂时迁移属性。在您的应用程序迁移期间，这个模块是必备的：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-properties-migrator<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>注意：完成迁移后，请确保从项目的依赖关系中删除此模块。</p>
<h3 id="构建您的-Spring-Boot-应用程序"><a href="#构建您的-Spring-Boot-应用程序" class="headerlink" title="构建您的 Spring Boot 应用程序"></a>构建您的 Spring Boot 应用程序</h3><h4 id="Spring-Boot-Maven-插件"><a href="#Spring-Boot-Maven-插件" class="headerlink" title="Spring Boot Maven 插件"></a>Spring Boot Maven 插件</h4><p>为了保持了一致性，并且避免与其他插件发生冲突，现在暴露的插件配置属性都以一个<code>spring-boot</code>前缀开始。</p>
<p>例如，以下命令<code>prod</code>使用命令行启用配置文件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mvn spring-boot:run -Dspring-boot.run.profiles=prod</span><br></pre></td></tr></table></figure>
<h5 id="Surefire-默认值"><a href="#Surefire-默认值" class="headerlink" title="Surefire 默认值"></a>Surefire 默认值</h5><p>以前的 <code>include/exclude</code> 模式已与最新的 Surefire 默认设置保持一致。如果依赖于此插件，需要相应地更新插件配置。之前对应的配置如下：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>maven-surefire-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">includes</span>&gt;</span></span><br><span class="line">			 <span class="tag">&lt;<span class="name">include</span>&gt;</span>**/*Tests.java<span class="tag">&lt;/<span class="name">include</span>&gt;</span></span><br><span class="line">			 <span class="tag">&lt;<span class="name">include</span>&gt;</span>**/*Test.java<span class="tag">&lt;/<span class="name">include</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">includes</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">excludes</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">exclude</span>&gt;</span>**/Abstract*.java<span class="tag">&lt;/<span class="name">exclude</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">excludes</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>PS: 如果您使用 JUnit 5，则应将 Surefire 降级到 <code>2.19.1</code>。该<code>**/*Tests.java</code>版本不包含此模式，因此如果您依赖该模式，请确保将其添加到您的配置中。</p>
<h4 id="Spring-Boot-Gradle-插件"><a href="#Spring-Boot-Gradle-插件" class="headerlink" title="Spring Boot Gradle 插件"></a>Spring Boot Gradle 插件</h4><p>Spring Boot 的 Gradle 插件在很大程度上已被重写，有了重大的改进。您可以在其<a href="https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/gradle-plugin/reference">参考文献</a>和<a href="https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/gradle-plugin/api">API</a>文档中阅读关于插件功能的更多信息。</p>
<h5 id="依赖管理"><a href="#依赖管理" class="headerlink" title="依赖管理"></a>依赖管理</h5><p>Spring Boot 的 Gradle 插件不再自动应用依赖管理插件。相反，Spring Boot 的插件现在可以通过导入正确版本的spring-boot-dependencies BOM 来应用依赖管理插件。当依赖管理被配置的时候，这一点会让你有更多的控制权。</p>
<p>对于大多数应用程序，使用应用依赖管理插件就足够了：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">apply plugin: &apos;org.springframework.boot&apos;</span><br><span class="line">apply plugin: &apos;io.spring.dependency-management&apos; // &lt;-- add this to your build.gradle</span><br></pre></td></tr></table></figure>
<p>注意：依赖管理插件仍然是 spring-boot-gradle-plugin 的传递依赖项，所以不需要在 buildscript 配置中将其列为类路径依赖项。</p>
<h5 id="建立可执行的-Jars-和-Wars"><a href="#建立可执行的-Jars-和-Wars" class="headerlink" title="建立可执行的 Jars 和 Wars"></a>建立可执行的 Jars 和 Wars</h5><p> <code>bootRepackage</code> 任务已经被替换成 <code>bootJar</code> 和 <code>bootWar</code> 任务，分别用于构建可执行的 <code>jar</code> 包和 <code>war</code>包。</p>
<h5 id="配置更新"><a href="#配置更新" class="headerlink" title="配置更新"></a>配置更新</h5><p><code>BootRun</code>，<code>BootJar</code>和<code>BootWar</code>任务现在都使用<code>mainClassName</code>的属性来配置主类的名称。这使得三个特定于引导的任务相互一致，并将其与 Gradle 自己的应用程序插件进行对齐。</p>
<h3 id="Spring-Boot-特性"><a href="#Spring-Boot-特性" class="headerlink" title="Spring Boot 特性"></a>Spring Boot 特性</h3><h4 id="默认动态代理策略"><a href="#默认动态代理策略" class="headerlink" title="默认动态代理策略"></a>默认动态代理策略</h4><p>Spring Boot 默认使用 CGLIB 做动态代理代理(基于类的动态代理)，包括对 AOP 的支持。如果你需要基于接口的动态代理，你需要将<code>spring.aop.proxy-target-class</code> 设置为<code>false</code>。</p>
<h4 id="SpringApplication"><a href="#SpringApplication" class="headerlink" title="SpringApplication"></a>SpringApplication</h4><h5 id="Web-环境"><a href="#Web-环境" class="headerlink" title="Web 环境"></a>Web 环境</h5><p>Spring Boot 应用程序现在可以在更多模式下运行，因此<code>spring.main.web-environment</code>现在不推荐使用，<code>spring.main.web-application-type</code>属性可以提供更多的支持。</p>
<p>如果您想确保应用程序不启动 Web 服务器，则必须将该属性更改为：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">spring.main.web-application-type=none</span><br></pre></td></tr></table></figure>
<p>注意：可以通过  <code>SpringApplication</code> 的 <code>setWebApplicationType</code> 方法实现。</p>
<h5 id="Spring-Boot-应用程序事件更改"><a href="#Spring-Boot-应用程序事件更改" class="headerlink" title="Spring Boot 应用程序事件更改"></a>Spring Boot 应用程序事件更改</h5><p>我们已经添加了一个新事件<code>ApplicationStartedEvent</code>。 <code>ApplicationStartedEvent</code>在上下文刷新之后但在任何应用程序和命令行参数被调用之前发送。 <code>ApplicationReadyEvent</code>在任何应用程序和命令行参数被调用后发送。它表示应用程序已准备好为请求提供服务。</p>
<p>请参阅<a href="https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-application-events-and-listeners">更新的参考文档</a>。</p>
<h5 id="Banner"><a href="#Banner" class="headerlink" title="Banner"></a>Banner</h5><p>在我们限制 Spring Boot 使用的根名称空间的数量的过程中，与标志相关的属性已被重定位到<code>spring.banner</code>。</p>
<h4 id="外部化配置"><a href="#外部化配置" class="headerlink" title="外部化配置"></a>外部化配置</h4><h5 id="轻松的绑定"><a href="#轻松的绑定" class="headerlink" title="轻松的绑定"></a>轻松的绑定</h5><p>有关宽松绑定的规则已经收紧。我们假设一个现有的<code>acme.my-project.my-name</code>属性：</p>
<ol>
<li>所有前缀必须是 kebab格式（小写，连字符分隔）<code>acme.myProject</code>或<code>acme.my_project</code>无效 - 您必须<code>acme.my-project</code>在此处使用。</li>
<li>属性名称可以使用 kebab-case（<code>my-name</code>），camel-case（<code>myName</code>）或 snake-case（<code>my_name</code>）。</li>
<li>环境属性（来自操作系统环境变量）<em>必须使用</em>通常的大写下划线格式，下划线<em>只能</em>用于分隔键的各个部分<code>ACME_MYPROJECT_MYNAME</code>。</li>
</ol>
<p>这种新的放松绑定具有以下几个优点：</p>
<ul>
<li>无需担心密钥的结构<code>@ConditionalOnProperty</code>：只要密钥是以规范格式定义的，支持的松散变体就可以透明地工作。如果您正在使用该<code>prefix</code>属性，则现在只需使用<code>name</code>或<code>value</code>属性即可放置完整密钥。</li>
<li><code>RelaxedPropertyResolver</code>不再可以<code>Environment</code>自动处理：<code>env.getProperty(&quot;com.foo.my-bar&quot;)</code>将找到一个<code>com.foo.myBar</code>属性。</li>
</ul>
<p>该<code>org.springframework.boot.bind</code>软件包不再可用，并被<a href="https://github.com/spring-projects/spring-boot/wiki/Relaxed-Binding-2.0">新的宽松绑定规则</a>所取代。特别是，<code>RelaxedDataBinder</code>朋友已被新的<code>Binder</code>API 取代。以下样品<code>MyProperties</code>从<code>app.acme</code>前缀中进行绑定。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">MyProperties target = Binder.get(environment)</span><br><span class="line">		.bind(<span class="string">"app.acme"</span>, MyProperties.class)</span><br><span class="line">		.orElse(<span class="keyword">null</span>);</span><br></pre></td></tr></table></figure>
<p>由于现在内置了轻松绑定，因此只要使用其中一种支持的格式，就可以请求任何属性而不必关心案例：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">FlagType flagType = Binder.get(environment)</span><br><span class="line">		.bind(<span class="string">"acme.app.my-flag"</span>, FlagType.class)</span><br><span class="line">		.orElse(FlagType.DEFAULT);</span><br></pre></td></tr></table></figure>
<h5 id="ConfigurationProperties-验证"><a href="#ConfigurationProperties-验证" class="headerlink" title="@ConfigurationProperties 验证"></a><code>@ConfigurationProperties</code> 验证</h5><p>如果您想打开验证，现在必须为您的<code>@ConfigurationProperties</code>对象添加注释<code>@Validated</code>。</p>
<h5 id="配置位置"><a href="#配置位置" class="headerlink" title="配置位置"></a>配置位置</h5><p><code>spring.config.location</code>配置的方式已被修复; 它提前将一个位置添加到默认位置列表中，现在它将替换默认位置。如果你是按照以前的方式进行处理，现在应该使用它<code>spring.config.additional-location</code>进行替换。</p>
<h4 id="开发-Web-应用程序"><a href="#开发-Web-应用程序" class="headerlink" title="开发 Web 应用程序"></a>开发 Web 应用程序</h4><h5 id="嵌入式容器包装结构"><a href="#嵌入式容器包装结构" class="headerlink" title="嵌入式容器包装结构"></a>嵌入式容器包装结构</h5><p>为了支持响应式用例，嵌入式容器包结构已经被大幅度的重构。 <code>EmbeddedServletContainer</code>已被重新命名为，<code>WebServer</code>并且该<code>org.springframework.boot.context.embedded</code>包已被重新定位到<code>org.springframework.boot.web.embedded</code>。例如，如果您使用<code>TomcatEmbeddedServletContainerFactory</code>回调接口定制嵌入式 Tomcat 容器，则应该使用<code>TomcatServletWebServerFactory</code>。</p>
<h5 id="特定于-Servlet-的服务器属性"><a href="#特定于-Servlet-的服务器属性" class="headerlink" title="特定于 Servlet 的服务器属性"></a>特定于 Servlet 的服务器属性</h5><p>许多<code>server.*</code> 属性 ( Servlet 特有的) 已经转移到<code>server.servlet</code>：</p>
<table>
<thead>
<tr>
<th style="text-align:center">旧的属性</th>
<th style="text-align:center">新的属性</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">server.context-parameters.*</td>
<td style="text-align:center">server.servlet.context-parameters.*</td>
</tr>
<tr>
<td style="text-align:center">server.context-path</td>
<td style="text-align:center">server.servlet.context-path</td>
</tr>
<tr>
<td style="text-align:center">server.jsp.class-name</td>
<td style="text-align:center">server.servlet.jsp.class-name</td>
</tr>
<tr>
<td style="text-align:center">server.jsp.init-parameters.*</td>
<td style="text-align:center">server.servlet.jsp.init-parameters.*</td>
</tr>
<tr>
<td style="text-align:center">server.jsp.registered</td>
<td style="text-align:center">server.servlet.jsp.registered</td>
</tr>
<tr>
<td style="text-align:center">server.servlet-path</td>
<td style="text-align:center">server.servlet.path</td>
</tr>
</tbody>
</table>
<h5 id="Web-Starter-作为传递依赖"><a href="#Web-Starter-作为传递依赖" class="headerlink" title="Web Starter 作为传递依赖"></a>Web Starter 作为传递依赖</h5><p>以前有几个 Spring Boot starter 是依赖于 Spring MVC 而传递的<code>spring-boot-starter-web</code>。在 <code>Spring WebFlux</code> 新的支持下，<code>spring-boot-starter-mustache</code>，<code>spring-boot-starter-freemarker</code>并<code>spring-boot-starter-thymeleaf</code>不再依赖它。开发者有责任选择和添加<code>spring-boot-starter-web</code>或<code>spring-boot-starter-webflux</code>。</p>
<h5 id="模板引擎"><a href="#模板引擎" class="headerlink" title="模板引擎"></a>模板引擎</h5><p>Mustache 模板曾经的文件扩展名是<code>.html</code>，现在的扩展名为 <code>.mustache</code> ，与官方规范和大多数 IDE 插件一致。您可以通过更改<code>spring.mustache.suffix</code>配置键来覆盖此新的默认值。</p>
<h5 id="Jackson-JSON-支持"><a href="#Jackson-JSON-支持" class="headerlink" title="Jackson / JSON 支持"></a>Jackson / JSON 支持</h5><p>在 2.0 中，我们改变了 Jackson 配置的默认值，将 ISO-8601 字符串 写为 JSR-310 日期 。如果你想回到以前的行为，你可以添加<code>spring.jackson.serialization.write-dates-as-timestamps=true</code>到你的配置。</p>
<p>新的<code>spring-boot-starter-json</code> starter 收集了必要的位去读写 JSON。它不仅提供了<code>jackson-databind</code>，而且提供了和 Java8 一起运作的时候相当有用的组件：<code>jackson-datatype-jdk8</code>,  <code>jackson-datatype-jsr310</code> 和 <code>jackson-module-parameter-names</code>。如果你曾经手动地依赖这些组件，现在可以依赖这个新的 starter 取代。</p>
<h5 id="Spring-MVC-路径匹配默认行为更改"><a href="#Spring-MVC-路径匹配默认行为更改" class="headerlink" title="Spring MVC 路径匹配默认行为更改"></a>Spring MVC 路径匹配默认行为更改</h5><p>我们已决定在 Spring MVC 应用程序中更改后缀路径匹配的默认值（请参阅<a href="https://github.com/spring-projects/spring-boot/issues/11105">＃11105</a>）。按照 Spring Framework 中记录的<a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#mvc-ann-requestmapping-suffix-pattern-match">最佳实践</a>，此功能不再默认启用。</p>
<p>如果您的应用程序希望将请求<code>&quot;GET /projects/spring-boot.json&quot;</code>映射到<code>@GetMapping(&quot;/projects/spring-boot&quot;)</code>映射，则此更改会影响您。</p>
<p>有关此更多信息以及如何减轻此更改，请查阅<a href="https://docs.spring.io/spring-boot/docs/2.0.0.RC1/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-pathmatch">Spring Boot中有关路径匹配和内容协商的参考文档</a>。</p>
<h5 id="Servlet-过滤器"><a href="#Servlet-过滤器" class="headerlink" title="Servlet 过滤器"></a>Servlet 过滤器</h5><p>Servlet 过滤器的默认调度程序类型现在是<code>DipatcherType.REQUEST</code>; 这使 Spring Boot 的默认值与 Servlet 规范的默认值一致。如果您希望将过滤器映射到其他调度程序类型，请使用<code>FilterRegistrationBean</code>注册您的过滤器。</p>
<p>注意：Spring Security 和 Spring Session 过滤器配置  <code>ASYNC</code>, <code>ERROR</code>以及 <code>REQUEST</code> 调度类型。</p>
<h5 id="RestTemplateBuilder"><a href="#RestTemplateBuilder" class="headerlink" title="RestTemplateBuilder"></a>RestTemplateBuilder</h5><p>该<code>requestFactory(ClientHttpRequestFactory)</code>方法已被新<code>requestFactory(Supplier&lt;ClientHttpRequestFactory&gt; requestFactorySupplier)</code>方法所取代。<code>Supplier</code>允许构建器生成的每个模板使用它自己的请求工厂，从而避免共享工厂可能导致的副作用。见<a href="https://github.com/spring-projects/spring-boot/issues/11255">＃11255</a>。</p>
<h5 id="WebJars-定位器"><a href="#WebJars-定位器" class="headerlink" title="WebJars 定位器"></a>WebJars 定位器</h5><p>Spring Boot 1.x 使用并提供依赖关系管理<code>org.webjars:webjars-locator</code>。<code>webjars-locator</code>是一个<a href="https://github.com/webjars/webjars-locator/tree/ec6b793f2d6f031f6aa384a06c059ff499055652">“命名不佳的库……包装<code>webjars-locator-core</code>项目”</a>。<code>org.webjars:webjars-locator</code>应该更新依赖项来<code>org.webjars:webjars-locator-core</code>代替使用。</p>
<h4 id="Security"><a href="#Security" class="headerlink" title="Security"></a>Security</h4><p>Spring Boot 2 极大地简化了默认的安全配置，并使添加定制安全变得简单。Spring Boot 现在具有一种行为，只要您添加自己的 <code>WebSecurityConfigurerAdapter</code> 就会退出，而不是进行多种与安全性相关的自动配置。</p>
<p>如果您使用以下任何属性，则会受到影响：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">security.basic.authorize-mode</span><br><span class="line">security.basic.enabled</span><br><span class="line">security.basic.path</span><br><span class="line">security.basic.realm</span><br><span class="line">security.enable-csrf</span><br><span class="line">security.headers.cache</span><br><span class="line">security.headers.content-security-policy</span><br><span class="line">security.headers.content-security-policy-mode</span><br><span class="line">security.headers.content-type</span><br><span class="line">security.headers.frame</span><br><span class="line">security.headers.hsts</span><br><span class="line">security.headers.xss</span><br><span class="line">security.ignored</span><br><span class="line">security.require-ssl</span><br><span class="line">security.sessions</span><br></pre></td></tr></table></figure>
<h5 id="默认安全"><a href="#默认安全" class="headerlink" title="默认安全"></a>默认安全</h5><p>安全自动配置不再公开选项，并尽可能使用 Spring Security 默认值。一个明显的副作用是使用 Spring Security 的内容协商进行授权（表单登录）。</p>
<h5 id="默认用户"><a href="#默认用户" class="headerlink" title="默认用户"></a>默认用户</h5><p>默认情况下，Spring Boot 使用生成的密码配置单个用户。用户可以使用 <code>spring.security.user.*</code> 属性进行配置。要进一步定制用户或添加其他用户，您将不得不公开一个<code>UserDetailsService</code>bean。</p>
<h5 id="AuthenticationManager-Bean"><a href="#AuthenticationManager-Bean" class="headerlink" title="AuthenticationManager Bean"></a>AuthenticationManager Bean</h5><p>如果您想将 Spring Security <code>AuthenticationManager</code>作为 bean 公开，请覆盖<code>authenticationManagerBean</code>您的方法<code>WebSecurityConfigurerAdapter</code>并为其添加注释<code>@Bean</code>。</p>
<h5 id="OAuth2"><a href="#OAuth2" class="headerlink" title="OAuth2"></a>OAuth2</h5><p>从功能的 <a href="http://projects.spring.io/spring-security-oauth/">Spring Security OAuth 项目</a> 迁移到核心 <a href="https://projects.spring.io/spring-security/">Spring Security</a>。不再为依赖关系提供依赖管理，Spring Boot 2 通过 Spring Security 5 提供 <a href="https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-security-oauth2">OAuth 2.0 客户端支持</a>。</p>
<p>如果您依赖尚未迁移的 Spring Security OAuth 功能，则需要在其他 jar 上添加依赖项，请查看<a href="https://docs.spring.io/spring-security-oauth2-boot/docs/current/reference/htmlsingle/">文档</a>以获取更多详细信息。我们还继续支持 Spring Boot 1.5，以便旧版应用程序可以继续使用它，直到提供升级路径。</p>
<h5 id="执行器安全"><a href="#执行器安全" class="headerlink" title="执行器安全"></a>执行器安全</h5><p>执行器不再有单独的安全自动配置（<code>management.security.*</code>属性消失）。<code>sensitive</code>每个端点的标志也没有在安全配置中变得更加明确。如果您依赖于此行为，则需要创建或调整您的安全配置，以保护您选择角色的端点。</p>
<p>例如，假设以下配置：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">endpoints.flyway.sensitive=false</span><br><span class="line">endpoints.info.sensitive=true</span><br><span class="line">management.security.roles=MY_ADMIN</span><br></pre></td></tr></table></figure>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">http</span><br><span class="line">	.authorizeRequests()</span><br><span class="line">	.requestMatchers(EndpointRequest.to(<span class="string">"health"</span>, <span class="string">"flyway"</span>)).permitAll()</span><br><span class="line">		.requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole(<span class="string">"MY_ADMIN"</span>)</span><br><span class="line">		...</span><br></pre></td></tr></table></figure>
<p>需要注意的是在<code>2.x</code>，<code>health</code>和<code>info</code>在默认情况下启用（与<code>health</code>默认情况下不显示其细节）。为了与这些新的默认值一致，<code>health</code>已被添加到第一个匹配器。</p>
<h4 id="使用-SQL-数据库"><a href="#使用-SQL-数据库" class="headerlink" title="使用 SQL 数据库"></a>使用 SQL 数据库</h4><h5 id="配置数据源"><a href="#配置数据源" class="headerlink" title="配置数据源"></a>配置数据源</h5><p>默认连接池已从 Tomcat 切换到 HikariCP。如果您过去<code>spring.datasource.type</code>在基于 Tomcat 的应用程序中强制使用 Hikari，现在可以删除重写。</p>
<p>特别是，如果你有这样的设置：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-data-jpa<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">exclusions</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">exclusion</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.tomcat<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>tomcat-jdbc<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">exclusion</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">exclusions</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.zaxxer<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>HikariCP<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>现在可以这样修改：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-data-jpa<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h5 id="WARN-消息隐含的’打开在视图’"><a href="#WARN-消息隐含的’打开在视图’" class="headerlink" title="WARN 消息隐含的’打开在视图’"></a>WARN 消息隐含的’打开在视图’</h5><p>从现在起，未明确启用的应用程序<code>spring.jpa.open-in-view</code>将在启动过程中收到警告消息。虽然这种行为是一种友好的默认行为，但如果您没有完全意识到为您做了什么，这可能会导致问题。此消息可确保您了解可在查看呈现期间执行数据库查询。如果你没有问题，你可以明确地配置这个属性来消除警告信息。</p>
<h5 id="JPA-和-Spring-Data"><a href="#JPA-和-Spring-Data" class="headerlink" title="JPA 和 Spring Data"></a>JPA 和 Spring Data</h5><p>在 Spring Boot 1.x 中，一些用户正在扩展<code>HibernateJpaAutoConfiguration</code>以将高级自定义应用于自动配置<code>EntityManagerFactory</code>。为了防止发生这种错误的用例，Spring Boot 2 中不再可能扩展它。</p>
<p>为了支持这些用例，现在可以定义一个<code>HibernatePropertiesCustomizer</code>bean，它可以完全控制 Hibernate 属性，包括注册在上下文中声明为 bean 的 Hibernate 拦截器的能力。</p>
<h5 id="Flyway"><a href="#Flyway" class="headerlink" title="Flyway"></a>Flyway</h5><p>Flyway 配置键被移动到<code>spring</code>命名空间（即<code>spring.flyway</code>）</p>
<p>升级到 Spring Boot 2 将会将 Flyway 升级<code>3.x</code>到<code>5.x</code>。为确保模式升级顺利进行，请按照以下说明操作：</p>
<ul>
<li>首先将您的<code>1.5.x</code>Spring Boot 应用程序升级到 Flyway 4，请参阅<a href="https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-boot-maven-parent-pom">Maven</a>和<a href="https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/gradle-plugin/reference/html//#managing-dependencies-customizing">Gradle</a>的说明。</li>
<li>一旦您的架构升级到了 Flyway 4，升级到 Spring Boot 2 并再次运行迁移以将您的应用程序移植到 Flyway 5。</li>
</ul>
<h5 id="Liquibase"><a href="#Liquibase" class="headerlink" title="Liquibase"></a>Liquibase</h5><p>Liquibase 配置键被移动到<code>spring</code>命名空间（即<code>spring.liquibase</code>）</p>
<h5 id="数据库初始化"><a href="#数据库初始化" class="headerlink" title="数据库初始化"></a>数据库初始化</h5><p>基本<code>DataSource</code>初始化现在仅针对嵌入式数据源启用，并将在您使用生产数据库时立即关闭。新的<code>spring.datasource.initialization-mode</code>（替换<code>spring.datasource.initialize</code>）提供更多的控制。</p>
<h5 id="更新默认的’创建-删除’处理"><a href="#更新默认的’创建-删除’处理" class="headerlink" title="更新默认的’创建 - 删除’处理"></a>更新默认的’创建 - 删除’处理</h5><p><code>spring.jpa.hibernate.ddl-auto</code> 属性默认为只有在没有使用 Liquibase 或 Flyway 等模式管理器时才使用嵌入式数据库进行创建。一旦检测到模式管理器，默认更改为 <code>none</code>。</p>
<h4 id="整合-NoSQL"><a href="#整合-NoSQL" class="headerlink" title="整合 NoSQL"></a>整合 NoSQL</h4><h5 id="Redis"><a href="#Redis" class="headerlink" title="Redis"></a>Redis</h5><p>现在使用的是 <a href="https://lettuce.io/">Lettuce</a> 而不是 <a href="https://github.com/xetorthio/jedis">Jedis</a> 作为 Redis 驱动程序<code>spring-boot-starter-redis</code>。如果您使用更高级别的Spring Data 构造，则应该发现变化是透明的。我们仍然支持 Jedis，如果您愿意，通过排除 <code>io.lettuce：lettuce-core</code>并添加 <code>redis.clients：jedis</code>，则可以自由切换依赖项。</p>
<h5 id="Elasticsearch"><a href="#Elasticsearch" class="headerlink" title="Elasticsearch"></a>Elasticsearch</h5><p>Elasticsearch 已经升级到 6.0+。与 <a href="https://www.elastic.co/blog/elasticsearch-the-server">Elastic 宣布嵌入式 Elasticsearch 不再受支持一致</a>，自动配置<code>NodeClient</code>已被删除。<code>TransportClient</code>可以通过使用<code>spring.data.elasticsearch.cluster-nodes</code>提供要连接的一个或多个节点的地址来自动配置。</p>
<h4 id="高速缓存"><a href="#高速缓存" class="headerlink" title="高速缓存"></a>高速缓存</h4><p>用于缓存的专用 Hazelcast 自动配置。</p>
<p>无法自动配置常规<code>HazelcastInstance</code>和专用<code>HazelcastInstance</code>缓存。因此，该<code>spring.cache.hazelcast.config</code>属性已不再可用。</p>
<h4 id="批量"><a href="#批量" class="headerlink" title="批量"></a>批量</h4><p>在启动时执行批处理作业的 CommandLineRunner 的顺序为 0。</p>
<h4 id="测试"><a href="#测试" class="headerlink" title="测试"></a>测试</h4><h5 id="Mockito-1-x"><a href="#Mockito-1-x" class="headerlink" title="Mockito 1.x"></a>Mockito 1.x</h5><p>Mockito 1.x 不再支持<code>@MockBean</code>和<code>@SpyBean</code>。如果你不用<code>spring-boot-starter-test</code>来管理你的依赖关系，你应该升级到 Mockito 2.x.</p>
<h3 id="Spring-Boot-Actuator"><a href="#Spring-Boot-Actuator" class="headerlink" title="Spring Boot Actuator"></a>Spring Boot Actuator</h3><p>Spring Boot 2 为 Actuator 带来了重要变化，无论是内部还是面向用户，请查阅<a href="https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#production-ready">参考指南中</a>的<a href="https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#production-ready">更新部分</a>和<a href="https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/actuator-api/html">新的Actuator API文档</a>。</p>
<p>您应该期望编程模型，配置密钥和某些端点的响应格式发生变化。Actuator 现在在 Spring MVC，Spring WebFlux 和Jersey 上得到本地支持。</p>
<h4 id="构建"><a href="#构建" class="headerlink" title="构建"></a>构建</h4><p>Actuator 的代码分为两个模块：现有的<code>spring-boot-actuator</code>和新的<code>spring-boot-actuator-autoconfigure</code>。如果您使用原始模块（<code>spring-boot-actuator</code>）导入 actuator，请考虑使用<code>spring-boot-starter-actuator</code>启动器替代它。</p>
<h4 id="Keys-的配置结构"><a href="#Keys-的配置结构" class="headerlink" title="Keys 的配置结构"></a>Keys 的配置结构</h4><p>Endpoints 基础配置 key 已经统一：</p>
<table>
<thead>
<tr>
<th style="text-align:center">旧的属性</th>
<th style="text-align:center">新的属性</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center"><code>endpoints.&lt;id&gt;.*</code></td>
<td style="text-align:center"><code>management.endpoint.&lt;id&gt;.*</code></td>
</tr>
<tr>
<td style="text-align:center"><code>endpoints.cors.*</code></td>
<td style="text-align:center"><code>management.endpoints.web.cors.*</code></td>
</tr>
<tr>
<td style="text-align:center"><code>endpoints.jmx.*</code></td>
<td style="text-align:center"><code>management.endpoints.jmx.*</code></td>
</tr>
<tr>
<td style="text-align:center"><code>management.address</code></td>
<td style="text-align:center"><code>management.server.address</code></td>
</tr>
<tr>
<td style="text-align:center"><code>management.context-path</code></td>
<td style="text-align:center"><code>management.server.servlet.context-path</code></td>
</tr>
<tr>
<td style="text-align:center"><code>management.ssl.*</code></td>
<td style="text-align:center"><code>management.server.ssl.*</code></td>
</tr>
<tr>
<td style="text-align:center"><code>management.port</code></td>
<td style="text-align:center">management.server.port</td>
</tr>
</tbody>
</table>
<h4 id="基本路径"><a href="#基本路径" class="headerlink" title="基本路径"></a>基本路径</h4><p>所有 endpoints 默认情况下都已移至 <code>/actuator</code>。</p>
<p>我们修改了 <code>management.server.servlet.context-path</code> 的含义：它现在是 <code>server.servlet.context-path</code> 的端点管理的等价替代（只有在设置了 <code>management.server.port</code> 时才有效）。另外，您还可以使用新的单独属性 <code>management.endpoints.web.base-path</code> 为管理端点设置基本路径。</p>
<p>例如，如果你设置<code>management.server.servlet.context-path=/management</code>和<code>management.endpoints.web.base-path=/application</code>，你就可以在下面的路径到达终点健康：<code>/management/application/health</code>。</p>
<p>如果你想恢复 1.x 的行为（即具有<code>/health</code>代替<code>/actuator/health</code>），设置以下属性：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">management.endpoints.web.base-path=/</span><br></pre></td></tr></table></figure>
<h4 id="审计事件-API-更改"><a href="#审计事件-API-更改" class="headerlink" title="审计事件 API 更改"></a>审计事件 API 更改</h4><p><code>AuditEventRepository</code> 现在有一个包含所有可选参数的单一方法。</p>
<h4 id="Endpoints"><a href="#Endpoints" class="headerlink" title="Endpoints"></a>Endpoints</h4><p>要通过 HTTP 使执行器端点可用，它需要同时<strong>启用</strong>和<strong>公开</strong>。默认：</p>
<ul>
<li><strong>无论您的应用程序中是否存在和配置 Spring Security</strong>，只有端点<code>/health</code>和<code>/info</code>端点都是暴露的。</li>
<li>所有端点，但<code>/shutdown</code>已启用。</li>
</ul>
<p>您可以按如下方式公开所有端点：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">management.endpoints.web.exposure.include=*</span><br></pre></td></tr></table></figure>
<p>您可以通过以下方式显式启用<code>/shutdown</code>端点：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">management.endpoint.shutdown.enabled=true</span><br></pre></td></tr></table></figure>
<p>要公开所有（已启用）网络端点除<code>env</code>端点之外：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">management.endpoints.web.exposure.include=*</span><br><span class="line">management.endpoints.web.exposure.exclude=env</span><br></pre></td></tr></table></figure>
<h5 id="Endpoint-changes"><a href="#Endpoint-changes" class="headerlink" title="Endpoint changes"></a>Endpoint changes</h5><table>
<thead>
<tr>
<th>1.x 端点</th>
<th>2.0 端点（改变）</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>/actuator</code></td>
<td>不再可用。 但是，在 <code>management.endpoints.web.base-path</code> 的根目录中有一个映射，它提供了到所有暴露端点的链接。</td>
</tr>
<tr>
<td><code>/auditevents</code></td>
<td>该<code>after</code>参数不再需要</td>
</tr>
<tr>
<td><code>/autoconfig</code></td>
<td>重命名为 <code>/conditions</code></td>
</tr>
<tr>
<td><code>/docs</code></td>
<td>不再可用</td>
</tr>
<tr>
<td><code>/health</code></td>
<td>现在有一个 <code>management.endpoint.health.show-details</code> 选项  <code>never</code>, <code>always</code>, <code>when-authenticated</code>，而不是依靠  <code>sensitive</code> 标志来确定 <code>health</code> 端点是否必须显示全部细节。  默认情况下，<code>/actuator/health</code>公开并且不显示细节。</td>
</tr>
<tr>
<td><code>/trace</code></td>
<td>重命名为 <code>/httptrace</code></td>
</tr>
</tbody>
</table>
<p>端点属性已更改如下：</p>
<ul>
<li><code>endpoints.&lt;id&gt;.enabled</code> 已经转移到了 <code>management.endpoint.&lt;id&gt;.enabled</code></li>
<li><code>endpoints.&lt;id&gt;.id</code> 没有替换（端点的 ID 不再可配置）</li>
<li><code>endpoints.&lt;id&gt;.sensitive</code>没有替代品（请参见<a href="https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide#actuator-security">执行器安全</a>）</li>
<li><code>endpoints.&lt;id&gt;.path</code> 已经转移到了 <code>management.endpoints.web.path-mapping.&lt;id&gt;</code></li>
</ul>
<h4 id="端点格式"><a href="#端点格式" class="headerlink" title="端点格式"></a>端点格式</h4><h5 id="actuator-mappings-端点大改变"><a href="#actuator-mappings-端点大改变" class="headerlink" title="/actuator/mappings 端点大改变"></a><code>/actuator/mappings</code> 端点大改变</h5><p>JSON 格式已经更改为现在正确地包含有关上下文层次结构，多个<code>DispatcherServlets，</code>部署的 Servlet 和 Servlet 过滤器的信息。详情请参阅<a href="https://github.com/spring-projects/spring-boot/issues/9979#issuecomment-357930821">＃9979</a>。</p>
<p>Actuator API 文档的<a href="https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/actuator-api/html/#mappings">相关部分</a>提供了一个示例文档。</p>
<h5 id="actuator-httptrace-端点大改变"><a href="#actuator-httptrace-端点大改变" class="headerlink" title="/actuator/httptrace 端点大改变"></a><code>/actuator/httptrace</code> 端点大改变</h5><p>响应的结构已经过改进，以反映端点关注跟踪 HTTP 请求 - 响应交换的情况。</p>
<h4 id="迁移自定义端点"><a href="#迁移自定义端点" class="headerlink" title="迁移自定义端点"></a>迁移自定义端点</h4><p>如果您有自定义执行器端点，请<a href="https://spring.io/blog/2017/08/22/introducing-actuator-endpoints-in-spring-boot-2-0">查看专用博客文章</a>。该团队还撰写了一个 wiki 页面，介绍<a href="https://github.com/spring-projects/spring-boot/wiki/Migrating-a-custom-Actuator-endpoint-to-Spring-Boot-2">如何将现有的执行器端点迁移</a>到新的基础架构。</p>
<h3 id="Metrics"><a href="#Metrics" class="headerlink" title="Metrics"></a>Metrics</h3><p>Spring Boot 自己的指标已被支持取代，包括自动配置，用于 <a href="https://micrometer.io/">icrometer</a>  和 dimensional 指标。</p>
<h4 id="设置-icrometer"><a href="#设置-icrometer" class="headerlink" title="设置 icrometer"></a>设置 icrometer</h4><p>如果您的 Spring Boot 2.0 应用程序已依赖于 Actuator，则 icrometer 已在此处并自动配置。如果您希望将度量标准导出到 Prometheus，Atlas 或 Datadog 等外部注册表，Micrometer 将为许多注册表提供依赖关系; 您可以使用<code>spring.metrics.*</code>属性配置您的应用程序以导出到特定的注册表。</p>
<h4 id="迁移定制计数器-量表"><a href="#迁移定制计数器-量表" class="headerlink" title="迁移定制计数器/量表"></a>迁移定制计数器/量表</h4><p>您可以通过以下方式创建各种指标，而不是在应用程序代码中注入<code>CounterService</code>或<code>GaugeService</code>的实例：</p>
<ul>
<li>注入<code>MeterRegistry</code>和调用方法。</li>
<li>直接调用静态方法<code>Counter featureCounter = Metrics.counter(&quot;feature&quot;);</code>。</li>
</ul>
<h3 id="开发者工具"><a href="#开发者工具" class="headerlink" title="开发者工具"></a>开发者工具</h3><h4 id="热拔插"><a href="#热拔插" class="headerlink" title="热拔插"></a>热拔插</h4><p>由于 Spring Loaded 项目被搁置，它在 Spring Boot 的支持已被删除。我们建议使用 Devtools。</p>
<h4 id="Devtools-远程调试隧道"><a href="#Devtools-远程调试隧道" class="headerlink" title="Devtools 远程调试隧道"></a>Devtools 远程调试隧道</h4><p>已经从 Devtools 中删除了对通过 HTTP 进行隧道远程调试的支持。</p>
<h3 id="已删除的功能"><a href="#已删除的功能" class="headerlink" title="已删除的功能"></a>已删除的功能</h3><p>以下功能不再可用：</p>
<ul>
<li>CRaSH 支持</li>
<li>Spring Mobile 的自动配置和依赖关系管理。</li>
<li>Spring Social 的自动配置和依赖关系管理。</li>
<li>依赖关系管理<code>commons-digester</code>。</li>
</ul>
<h3 id="依赖版本"><a href="#依赖版本" class="headerlink" title="依赖版本"></a>依赖版本</h3><p>以下库的最低支持版本已更改：</p>
<ul>
<li>Elasticsearch 5.6</li>
<li>Gradle 4</li>
<li>Hibernate 5.2</li>
<li>Jetty 9.4</li>
<li>Spring Framework 5</li>
<li>Spring Security 5</li>
<li>Tomcat 8.5</li>
</ul>
<h3 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h3><p><a href="">https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide</a></p>
<h3 id="相关文章"><a href="#相关文章" class="headerlink" title="相关文章"></a>相关文章</h3><p>1、<a href="http://www.54tianzhisheng.cn/2018/03/06/SpringBoot2-Migration-Guide/">Spring Boot 2.0系列文章(一)：Spring Boot 2.0 迁移指南</a></p>
<p>2、<a href="http://www.54tianzhisheng.cn/2018/03/06/SpringBoot2-new-features/">Spring Boot 2.0系列文章(二)：Spring Boot 2.0 新特性详解</a></p>
<p>3、<a href="http://www.54tianzhisheng.cn/2018/04/13/Spring_Boot_2.0_Configuration_Changelog/">Spring Boot 2.0系列文章(三)：Spring Boot 2.0 配置改变</a></p>
<p>4、<a href="http://www.54tianzhisheng.cn/2018/04/15/springboot2_code/">Spring Boot 2.0系列文章(四)：Spring Boot 2.0 源码阅读环境搭建</a></p>
<p>5、<a href="http://www.54tianzhisheng.cn/2018/04/18/spring_boot2_project/">Spring Boot 2.0系列文章(五)：Spring Boot 2.0 项目源码结构预览</a></p>
<p>6、<a href="http://www.54tianzhisheng.cn/2018/04/19/SpringBootApplication-annotation/">Spring Boot 2.0系列文章(六)：Spring boot 2.0 中 SpringBootApplication 注解详解</a></p>
<p>7、<a href="http://www.54tianzhisheng.cn/2018/04/30/springboot_SpringApplication/">Spring Boot 2.0系列文章(七)：SpringApplication 深入探索</a></p>

      
      
        <div class="page-reward">
          <p><a href="javascript:void(0)" onclick="dashangToggle()" class="dashang">赏</a></p>
          <div class="hide_box"></div>
          <div class="shang_box">
            <a class="shang_close" href="javascript:void(0)" onclick="dashangToggle()">×</a>
            <div class="shang_tit">
              <p>纯属好玩</p>
            </div>
            <div class="shang_payimg">
              <img src="/img/alipayimg.jpg" alt="扫码支持" title="扫一扫" />
            </div>
              <div class="pay_explain">扫码打赏，你说多少就多少</div>
            <div class="shang_payselect">
              
                <div class="pay_item checked" data-id="alipay">
                  <span class="radiobox"></span>
                  <span class="pay_logo"><img src="/img/alipay.png" alt="支付宝" /></span>
                </div>
              
              
                <div class="pay_item" data-id="wechat">
                  <span class="radiobox"></span>
                  <span class="pay_logo"><img src="/img/weixin.png" alt="微信" /></span>
                </div>
              
            </div>
            <div class="shang_info">
              <p>打开<span id="shang_pay_txt">支付宝</span>扫一扫，即可进行扫码打赏哦</p>
            </div>
          </div>
        </div>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.2.0/zepto.min.js"></script>
        <script type="text/javascript">
          $(".pay_item").click(function(){
            $(this).addClass('checked').siblings('.pay_item').removeClass('checked');
            var dataid=$(this).attr('data-id');
            $(".shang_payimg img").attr("src","/img/"+dataid+"img.jpg");
            $("#shang_pay_txt").text(dataid=="alipay"?"支付宝":"微信");
          });
          function dashangToggle(){
            
            $(".hide_box").fadeToggle();
            $(".shang_box").fadeToggle();
          }
        </script>
      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>本文标题:</span><a href="/2018/03/06/SpringBoot2-Migration-Guide/">Spring Boot 2.0系列文章(一)：Spring Boot 2.0 迁移指南</a></p>
        <p><span>文章作者:</span><a href="/" title="访问 zhisheng 的个人博客">zhisheng</a></p>
        <p><span>发布时间:</span>2018年03月06日 - 00时00分</p>
        <p><span>最后更新:</span>2018年11月22日 - 22时51分</p>
        <p>
            <span>原始链接:</span><a class="post-url" href="/2018/03/06/SpringBoot2-Migration-Guide/" title="Spring Boot 2.0系列文章(一)：Spring Boot 2.0 迁移指南">http://www.54tianzhisheng.cn/2018/03/06/SpringBoot2-Migration-Guide/</a>
            <span class="copy-path" data-clipboard-text="原文: http://www.54tianzhisheng.cn/2018/03/06/SpringBoot2-Migration-Guide/　　作者: zhisheng" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
            <script src="/js/clipboard.min.js"></script>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/cn/" title="中国大陆 (CC BY-NC-SA 3.0 CN)" target = "_blank">"署名-非商用-相同方式共享 3.0"</a> 转载请保留原文链接及作者。
        </p>
    </div>



<nav id="article-nav">
  
    <a href="/2018/03/06/SpringBoot2-new-features/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption"><</strong>
      <div class="article-nav-title">
        
          Spring Boot 2.0系列文章(二)：Spring Boot 2.0 新特性详解
        
      </div>
    </a>
  
  
    <a href="/2018/03/04/springboot-vedio/" id="article-nav-older" class="article-nav-link-wrap">
      <div class="article-nav-title">小马哥 《Java 微服务实践 - Spring Boot 系列》强烈推荐</div>
      <strong class="article-nav-caption">></strong>
    </a>
  
</nav>

  
</article>

    <div id="toc" class="toc-article">
    <strong class="toc-title">文章目录</strong>
    <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#前提"><span class="toc-number">1.</span> <span class="toc-text">前提</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#关注我"><span class="toc-number">2.</span> <span class="toc-text">关注我</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#在你开始之前"><span class="toc-number">3.</span> <span class="toc-text">在你开始之前</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#构建您的-Spring-Boot-应用程序"><span class="toc-number">4.</span> <span class="toc-text">构建您的 Spring Boot 应用程序</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#Spring-Boot-Maven-插件"><span class="toc-number">4.1.</span> <span class="toc-text">Spring Boot Maven 插件</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#Surefire-默认值"><span class="toc-number">4.1.1.</span> <span class="toc-text">Surefire 默认值</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Spring-Boot-Gradle-插件"><span class="toc-number">4.2.</span> <span class="toc-text">Spring Boot Gradle 插件</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#依赖管理"><span class="toc-number">4.2.1.</span> <span class="toc-text">依赖管理</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#建立可执行的-Jars-和-Wars"><span class="toc-number">4.2.2.</span> <span class="toc-text">建立可执行的 Jars 和 Wars</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#配置更新"><span class="toc-number">4.2.3.</span> <span class="toc-text">配置更新</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Spring-Boot-特性"><span class="toc-number">5.</span> <span class="toc-text">Spring Boot 特性</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#默认动态代理策略"><span class="toc-number">5.1.</span> <span class="toc-text">默认动态代理策略</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#SpringApplication"><span class="toc-number">5.2.</span> <span class="toc-text">SpringApplication</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#Web-环境"><span class="toc-number">5.2.1.</span> <span class="toc-text">Web 环境</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Spring-Boot-应用程序事件更改"><span class="toc-number">5.2.2.</span> <span class="toc-text">Spring Boot 应用程序事件更改</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Banner"><span class="toc-number">5.2.3.</span> <span class="toc-text">Banner</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#外部化配置"><span class="toc-number">5.3.</span> <span class="toc-text">外部化配置</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#轻松的绑定"><span class="toc-number">5.3.1.</span> <span class="toc-text">轻松的绑定</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#ConfigurationProperties-验证"><span class="toc-number">5.3.2.</span> <span class="toc-text">@ConfigurationProperties 验证</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#配置位置"><span class="toc-number">5.3.3.</span> <span class="toc-text">配置位置</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#开发-Web-应用程序"><span class="toc-number">5.4.</span> <span class="toc-text">开发 Web 应用程序</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#嵌入式容器包装结构"><span class="toc-number">5.4.1.</span> <span class="toc-text">嵌入式容器包装结构</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#特定于-Servlet-的服务器属性"><span class="toc-number">5.4.2.</span> <span class="toc-text">特定于 Servlet 的服务器属性</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Web-Starter-作为传递依赖"><span class="toc-number">5.4.3.</span> <span class="toc-text">Web Starter 作为传递依赖</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#模板引擎"><span class="toc-number">5.4.4.</span> <span class="toc-text">模板引擎</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Jackson-JSON-支持"><span class="toc-number">5.4.5.</span> <span class="toc-text">Jackson / JSON 支持</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Spring-MVC-路径匹配默认行为更改"><span class="toc-number">5.4.6.</span> <span class="toc-text">Spring MVC 路径匹配默认行为更改</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Servlet-过滤器"><span class="toc-number">5.4.7.</span> <span class="toc-text">Servlet 过滤器</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#RestTemplateBuilder"><span class="toc-number">5.4.8.</span> <span class="toc-text">RestTemplateBuilder</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#WebJars-定位器"><span class="toc-number">5.4.9.</span> <span class="toc-text">WebJars 定位器</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Security"><span class="toc-number">5.5.</span> <span class="toc-text">Security</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#默认安全"><span class="toc-number">5.5.1.</span> <span class="toc-text">默认安全</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#默认用户"><span class="toc-number">5.5.2.</span> <span class="toc-text">默认用户</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#AuthenticationManager-Bean"><span class="toc-number">5.5.3.</span> <span class="toc-text">AuthenticationManager Bean</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#OAuth2"><span class="toc-number">5.5.4.</span> <span class="toc-text">OAuth2</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#执行器安全"><span class="toc-number">5.5.5.</span> <span class="toc-text">执行器安全</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#使用-SQL-数据库"><span class="toc-number">5.6.</span> <span class="toc-text">使用 SQL 数据库</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#配置数据源"><span class="toc-number">5.6.1.</span> <span class="toc-text">配置数据源</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#WARN-消息隐含的’打开在视图’"><span class="toc-number">5.6.2.</span> <span class="toc-text">WARN 消息隐含的’打开在视图’</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#JPA-和-Spring-Data"><span class="toc-number">5.6.3.</span> <span class="toc-text">JPA 和 Spring Data</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Flyway"><span class="toc-number">5.6.4.</span> <span class="toc-text">Flyway</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Liquibase"><span class="toc-number">5.6.5.</span> <span class="toc-text">Liquibase</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#数据库初始化"><span class="toc-number">5.6.6.</span> <span class="toc-text">数据库初始化</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#更新默认的’创建-删除’处理"><span class="toc-number">5.6.7.</span> <span class="toc-text">更新默认的’创建 - 删除’处理</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#整合-NoSQL"><span class="toc-number">5.7.</span> <span class="toc-text">整合 NoSQL</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#Redis"><span class="toc-number">5.7.1.</span> <span class="toc-text">Redis</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Elasticsearch"><span class="toc-number">5.7.2.</span> <span class="toc-text">Elasticsearch</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#高速缓存"><span class="toc-number">5.8.</span> <span class="toc-text">高速缓存</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#批量"><span class="toc-number">5.9.</span> <span class="toc-text">批量</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#测试"><span class="toc-number">5.10.</span> <span class="toc-text">测试</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#Mockito-1-x"><span class="toc-number">5.10.1.</span> <span class="toc-text">Mockito 1.x</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Spring-Boot-Actuator"><span class="toc-number">6.</span> <span class="toc-text">Spring Boot Actuator</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#构建"><span class="toc-number">6.1.</span> <span class="toc-text">构建</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Keys-的配置结构"><span class="toc-number">6.2.</span> <span class="toc-text">Keys 的配置结构</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#基本路径"><span class="toc-number">6.3.</span> <span class="toc-text">基本路径</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#审计事件-API-更改"><span class="toc-number">6.4.</span> <span class="toc-text">审计事件 API 更改</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Endpoints"><span class="toc-number">6.5.</span> <span class="toc-text">Endpoints</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#Endpoint-changes"><span class="toc-number">6.5.1.</span> <span class="toc-text">Endpoint changes</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#端点格式"><span class="toc-number">6.6.</span> <span class="toc-text">端点格式</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#actuator-mappings-端点大改变"><span class="toc-number">6.6.1.</span> <span class="toc-text">/actuator/mappings 端点大改变</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#actuator-httptrace-端点大改变"><span class="toc-number">6.6.2.</span> <span class="toc-text">/actuator/httptrace 端点大改变</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#迁移自定义端点"><span class="toc-number">6.7.</span> <span class="toc-text">迁移自定义端点</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Metrics"><span class="toc-number">7.</span> <span class="toc-text">Metrics</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#设置-icrometer"><span class="toc-number">7.1.</span> <span class="toc-text">设置 icrometer</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#迁移定制计数器-量表"><span class="toc-number">7.2.</span> <span class="toc-text">迁移定制计数器/量表</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#开发者工具"><span class="toc-number">8.</span> <span class="toc-text">开发者工具</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#热拔插"><span class="toc-number">8.1.</span> <span class="toc-text">热拔插</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Devtools-远程调试隧道"><span class="toc-number">8.2.</span> <span class="toc-text">Devtools 远程调试隧道</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#已删除的功能"><span class="toc-number">9.</span> <span class="toc-text">已删除的功能</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#依赖版本"><span class="toc-number">10.</span> <span class="toc-text">依赖版本</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#参考资料"><span class="toc-number">11.</span> <span class="toc-text">参考资料</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#相关文章"><span class="toc-number">12.</span> <span class="toc-text">相关文章</span></a></li></ol>
</div>
<input type="button" id="tocButton" value="隐藏目录"  title="点击按钮隐藏或者显示文章目录">

<script src="https://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
<script>
    var valueHide = "隐藏目录";
    var valueShow = "显示目录";

    if ($(".left-col").is(":hidden")) {
        $("#tocButton").attr("value", valueShow);
    }
    $("#tocButton").click(function() {
        if ($("#toc").is(":hidden")) {
            $("#tocButton").attr("value", valueHide);
            $("#toc").slideDown(320);
        }
        else {
            $("#tocButton").attr("value", valueShow);
            $("#toc").slideUp(350);
        }
    })
    if ($(".toc").length < 1) {
        $("#toc, #tocButton").hide();
    }
</script>





<div class="bdsharebuttonbox">
	<a href="#" class="fx fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
	<a href="#" class="fx fa-weixin bds_weixin" data-cmd="weixin" title="分享到微信"></a>
	<a href="#" class="fx fa-qq bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
	<a href="#" class="fx fa-facebook-official bds_fbook" data-cmd="fbook" title="分享到Facebook"></a>
	<a href="#" class="fx fa-twitter bds_twi" data-cmd="twi" title="分享到Twitter"></a>
	<a href="#" class="fx fa-linkedin bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a>
	<a href="#" class="fx fa-files-o bds_copy" data-cmd="copy" title="分享到复制网址"></a>
</div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"2","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>




    
        <div id="gitments"></div>
<script src="/js/gitment.browser.js"></script>
<script>
    var gitment = new Gitment({
      id: window.location.pathname,
      owner: 'zhisheng',
      repo: 'zhisheng17.github.io',
      oauth: {
        client_id: '',
        client_secret: '',
      },
    })
    gitment.render('gitments')
</script>
    



    <div class="scroll" id="post-nav-button">
        
            <a href="/2018/03/06/SpringBoot2-new-features/" title="上一篇: Spring Boot 2.0系列文章(二)：Spring Boot 2.0 新特性详解">
                <i class="fa fa-angle-left"></i>
            </a>
        
        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>
        
            <a href="/2018/03/04/springboot-vedio/" title="下一篇: 小马哥 《Java 微服务实践 - Spring Boot 系列》强烈推荐">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>
    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/2019/01/06/Flink-Kafka-sink/">《从0到1学习Flink》—— Flink 写入数据到 Kafka</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/01/05/Flink-run/">《从0到1学习Flink》—— Flink 项目如何运行？</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/12/30/Flink-ElasticSearch-Sink/">《从0到1学习Flink》—— Flink 写入数据到 ElasticSearch</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/12/11/Flink-time/">《从0到1学习Flink》—— Flink 中几种 Time 详解</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/12/08/Flink-Stream-Windows/">《从0到1学习Flink》—— 介绍Flink中的Stream Windows</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/11/04/Flink-Data-transformation/">《从0到1学习Flink》—— Flink Data transformation(转换)</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/10/31/flink-create-sink/">《从0到1学习Flink》—— 如何自定义 Data Sink ？</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/10/30/flink-create-source/">《从0到1学习Flink》—— 如何自定义 Data Source ？</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/10/29/flink-sink/">《从0到1学习Flink》—— Data Sink 介绍</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/10/28/flink-sources/">《从0到1学习Flink》—— Data Source 介绍</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/10/27/flink-config/">《从0到1学习Flink》—— Flink 配置文件详解</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/10/13/flink-introduction/">《从0到1学习Flink》—— Apache Flink 介绍</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/09/18/flink-install/">《从0到1学习Flink》—— Mac 上搭建 Flink 1.6.0 环境并构建运行简单程序入门</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/08/30/go-sync/">Go 并发——实现协程同步的几种方式</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/08/14/idea-remote-debug-elasticsearch/">教你如何在 IDEA 远程 Debug ElasticSearch</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/08/12/es-code03/">渣渣菜鸡的 ElasticSearch 源码解析 —— 启动流程（下）</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/08/11/es-code02/">渣渣菜鸡的 ElasticSearch 源码解析 —— 启动流程（上）</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/08/05/es-code01/">渣渣菜鸡的 ElasticSearch 源码解析 —— 环境搭建</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/08/04/why-see-es-code/">渣渣菜鸡为什么要看 ElasticSearch 源码？</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/07/31/alipay02/">渣渣菜鸡的蚂蚁金服面试经历(二)</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/07/30/alipay01/">渣渣菜鸡的蚂蚁金服面试经历(一)</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/07/12/youzan/">渣渣菜鸡的有赞面试经历（一）</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/06/20/java-8-date/">20 个案例教你在 Java 8 中如何处理日期和时间?</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/06/19/SimpleDateFormat/">SimpleDateFormat 如何安全的使用？</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/05/26/paper/">苦逼的毕业论文经历</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/04/30/springboot_SpringApplication/">Spring Boot 2.0系列文章(七)：SpringApplication 深入探索</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/04/24/Distributed_lock/">分布式锁看这篇就够了</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/04/19/SpringBootApplication-annotation/">Spring Boot 2.0系列文章(六)：Spring Boot 2.0中SpringBootApplication注解详解</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/04/18/spring_boot2_project/">Spring Boot 2.0系列文章(五)：Spring Boot 2.0 项目源码结构预览</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/04/15/springboot2_code/">Spring Boot 2.0系列文章(四)：Spring Boot 2.0 源码阅读环境搭建</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/04/13/Spring_Boot_2.0_Configuration_Changelog/">Spring Boot 2.0系列文章(三)：Spring Boot 2.0 配置改变</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/03/27/blogs/">写这么多系列博客，怪不得找不到女朋友</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/03/06/SpringBoot2-new-features/">Spring Boot 2.0系列文章(二)：Spring Boot 2.0 新特性详解</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/03/06/SpringBoot2-Migration-Guide/">Spring Boot 2.0系列文章(一)：Spring Boot 2.0 迁移指南</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/03/04/springboot-vedio/">小马哥 《Java 微服务实践 - Spring Boot 系列》强烈推荐</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/03/04/springcloud-vedio/">小马哥 《Java 微服务实践 - Spring Cloud 系列》强烈推荐</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/02/28/Java-Memory-Model/">《深入理解 Java 内存模型》读书笔记</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/02/07/SpringBoot-RocketMQ/">Spring Boot系列文章（六）：SpringBoot RocketMQ 整合使用和监控</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/02/07/rocketmq-example/">RocketMQ系列文章（三）：RocketMQ 简单的消息示例</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/02/06/RocketMQ-install/">RocketMQ系列文章（二）：RocketMQ 安装及快速入门</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/02/05/RocketMQ/">RocketMQ系列文章（一）：RocketMQ 初探</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/01/28/RabbitMQ/">Spring Boot系列文章（五）：SpringBoot RabbitMQ 整合进阶版</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/01/27/SpringBoot-ActiveMQ/">Spring Boot系列文章（四）：SpringBoot ActiveMQ 整合使用</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/01/26/SpringBoot-RabbitMQ/">Spring Boot系列文章（三）：SpringBoot  RabbitMQ 整合使用</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/01/25/Docker-install/">Docker系列文章（二）：Mac 安装 Docker 及常用命令</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/01/24/mac/">MacBook Pro 初体验</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/01/17/SpringBoot-Admin/">Spring Boot系列文章（二）：SpringBoot Admin 使用指南</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/01/09/lombok/">Lombok 看这篇就够了</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/01/05/SpringBoot-Kafka/">Spring Boot系列文章（一）：SpringBoot Kafka 整合使用</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/01/04/Kafka/">Kafka 安装及快速入门</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/01/04/weixin/">为什么要重新运营以前的公众号呢？</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/12/27/consul-install/">Windows 下安装 Consul</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/12/25/ELK/">Elasticsearch 系列文章（五）：ELK 实时日志分析平台环境搭建</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/12/18/hexo-yilia/">Hexo + yilia 搭建博客可能会遇到的所有疑问</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/12/13/Google-Developer-Days/">谷歌开发者大会收获满满，不去真 “可惜” 了</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/12/09/CodeMirror/">使用 CodeMirror 打造属于自己的在线代码编辑器</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/12/08/netty-01-env/">Netty系列文章（一）：Netty 源码阅读之初始环境搭建</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/12/03/RestTemplate/">RestTemplate 详解</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/12/02/wx-01/">实习圈群里提问小记</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/11/26/Docker-harbor/">Docker系列文章（一）：基于 Harbor 搭建 Docker 私有镜像仓库</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/11/18/flow-control/">基于分布式环境下限流系统的设计</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/11/18/Money-management/">谈谈我的理财</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/11/11/recommended-books/">送你一份双十一剁手书单【墙裂推荐】</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/11/11/Maven-dependencies-dependencyManagement/">Maven 中 dependencies 与 dependencyManagement 的区别</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/10/28/Data-Desensitization/">小白谈数据脱敏</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/10/21/HBase-metrics/">HBase 集群监控</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/10/18/ElasticSearch-nodes-metrics/">Elasticsearch 系列文章（四）：ElasticSearch 单个节点监控</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/10/15/ElasticSearch-cluster-health-metrics/">Elasticsearch 系列文章（三）：ElasticSearch 集群监控</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/10/14/Nexus3-Maven/">Centos7 搭建最新 Nexus3 Maven 私服</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/10/14/JsonPath/">JsonPath —— JSON 解析神器</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/09/23/Guava-limit/">Google Guava 缓存实现接口的限流</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/09/17/Interview-summary/">面试过阿里等互联网大公司，我知道了这些套路</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/09/15/linux-lua-lfs-install/">Linux 下 lua 开发环境安装及安装 luafilesystem</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/09/09/Elasticsearch-install/">Elasticsearch 系列文章（二）：全文搜索引擎 Elasticsearch 集群搭建入门教程</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/09/08/Elasticsearch-analyzers/">Elasticsearch 系列文章（一）：Elasticsearch 默认分词器和中分分词器之间的比较及使用方法</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/28/recommend-books/">那些年我看过的书 —— 致敬我的大学生活 —— Say Good Bye ！</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/18/Ubuntu-install-Nginx/">Ubuntu16.10 安装 Nginx</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/11/most-success/">马云热血励志演讲《最伟大的成功》</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/08/android-projects/">源码大招：不服来战！撸这些完整项目，你不牛逼都难！</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/05/Nginx/">Nginx 基本知识快速入门</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/04/alibaba/">秋招第三站 —— 内推阿里（一面）</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/04/yaxin/">秋招第一站 —— 亚信科技</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/04/iqiyi/">秋招第二站 —— 内推爱奇艺（一面二面）</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/29/ThreadPool/">Java 线程池艺术探索</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/25/Java-performance-tuning/">Java 性能调优需要格外注意的细节</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/21/Spring-MVC03/">Spring MVC系列文章（五）：看透 Spring MVC 源代码分析与实践 ——  Spring MVC 组件分析</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/14/Spring-MVC01/">Spring MVC系列文章（三）：看透 Spring MVC 源代码分析与实践 ——  网站基础知识</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/14/Spring-MVC02/">Spring MVC系列文章（四）：看透 Spring MVC 源代码分析与实践 ——  俯视 Spring MVC</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/09/servlet/">通过源码详解 Servlet</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/28/Velocity-foreach/">Velocity 循环指令一种好的解决方法</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/23/java-io/">Java IO流学习超详细总结（图文并茂）</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/23/AJAX/">AJAX 学习</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/20/Java-error1/">java.sql.SQLException Field 'id' doesn't have a default value</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/19/中缀表达式转换成前缀和后缀表达式这类题目的超实用解题技巧/">中缀表达式转换成前缀和后缀表达式这类题目的超实用解题技巧</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/18/Bootstrap入门需掌握的知识点（二）/">Bootstrap入门需掌握的知识点（二）</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/18/Bootstrap入门需掌握的知识点（一）/">Bootstrap入门需掌握的知识点（一）</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/18/循环队列的相关条件和公式/">循环队列的相关条件和公式</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/17/详解 Filter 过滤器/">详解 Filter 过滤器</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/17/blog-talk/">搭建一个博客项目后的碎碎念</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/17/详细深入分析 Java ClassLoader 工作机制/">详细深入分析 Java ClassLoader 工作机制</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/16/通过项目逐步深入了解Spring MVC（一）/">通过项目逐步深入了解Spring MVC（一）</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/15/通过项目逐步深入了解Mybatis(四)/">通过项目逐步深入了解Mybatis（四）</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/14/通过项目逐步深入了解Mybatis(三)/">通过项目逐步深入了解Mybatis（三）</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/Hexo-yilia-toc/">Hexo + yilia 主题实现文章目录</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/HashMap-Hashtable/">HashMap、Hashtable、HashSet 和 ConcurrentHashMap 的比较</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/Spring MVC+Hibernate JPA搭建的博客系统项目中所遇到的坑/">Spring MVC系列文章（二）：Spring MVC+Hibernate JPA搭建的博客系统项目中所遇到的坑</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/Spring MVC + Hibernate JPA + Bootstrap 搭建的博客系统/">Spring MVC系列文章（一）：Spring MVC + Hibernate JPA + Bootstrap 搭建的博客系统 Demo</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/Java-Thread/">《Java 多线程编程核心技术》学习笔记及总结</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/Python爬虫实战之爬取糗事百科段子/">Python爬虫实战之爬取糗事百科段子</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/通过项目逐步深入了解Mybatis(二)/">通过项目逐步深入了解Mybatis（二）</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/Pyspider框架 —— Python爬虫实战之爬取 V2EX 网站帖子/">Pyspider框架 —— Python爬虫实战之爬取 V2EX 网站帖子</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/MySQL-select-good/">MySQL 处理海量数据时的一些优化查询速度方法</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/MyBatis-foreach/">MyBatis的foreach语句详解</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/Java连接Oracle数据库的三种连接方式/">Java连接Oracle数据库的三种连接方式</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/【字符串】判断两字符串是否互为旋转词？/">【字符串】判断两字符串是否互为旋转词？</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/【字符串】字符串逆序/">字符串</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/feiji/">记录下自己第一次坐飞机的感受</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/JVM性能调优监控工具jps、jstack、jmap、jhat、jstat等使用详解/">JVM性能调优监控工具jps、jstack、jmap、jhat、jstat等使用详解</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/Java-16-lession/">《疯狂 Java 突破程序员基本功的 16 课》读书笔记</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/奇怪的Java题：为什么128 == 128返回为False，而127 == 127会返回为True-/">奇怪的Java题：为什么128 == 128返回为False，而127 == 127会返回为True?</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/利用Github Page 搭建个人博客网站/">利用Github Page 搭建个人博客网站</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/深入分析 Java Web 中的中文编码问题/">深入分析 Java Web 中的中文编码问题</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/程序访问文件的几种方式/">程序访问文件的几种方式</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/深度探究Java 中 finally 语句块/">深度探究Java 中 finally 语句块</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/解决jdk1.8中发送邮件失败（handshake_failure）问题/">解决jdk1.8中发送邮件失败（handshake_failure）问题</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/java-var/">从对象深入分析 Java 中实例变量和类变量的区别</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/String-new/">关于String s = new String("xyz"); 创建几个对象的问题</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/java读取文件/">Java读取文件</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/Java NIO 系列教程/">Java NIO 系列教程</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/13/Python爬虫实战之爬取百度贴吧帖子/">Python爬虫实战之爬取百度贴吧帖子</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/12/通过项目逐步深入了解Mybatis(一)/">通过项目逐步深入了解Mybatis（一）</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/06/02/poetry2/"> 六月 —— 愿你做最美好的自己！</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/05/12/poetry/">最近很火的鸡汤，分享给大家</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/04/13/Hexo-yilia-changyan/">Github pages + Hexo 博客 yilia 主题使用畅言评论系统</a></li></ul>
    <script src="https://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
    <script>
        $(".post-list").addClass("toc-article");
        $(".post-list-item a").attr("target","_blank");
        $("#post-nav-button > a:nth-child(2)").click(function() {
            $(".fa-bars, .fa-times").toggle();
            $(".post-list").toggle(300);
            if ($(".toc").length > 0) {
                $("#toc, #tocButton").toggle(200, function() {
                    if ($(".switch-area").is(":visible")) {
                        $("#tocButton").attr("value", valueHide);
                        }
                    })
            }
            else {
            }
        })
    </script>



    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                &copy; 2019 zhisheng
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" >本站总访问量: 
                            <span id="busuanzi_value_site_pv"></span>
                        </span>
                    </span>
                
                
                    <span>, </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit">本文总阅读量: 
                            <span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>

    </div>
    <script src="https://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
<script src="/js/main.js"></script>

    <script>
        $(document).ready(function() {
            var backgroundnum = 24;
            var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
            $("#mobile-nav").css({"background-image": backgroundimg,"background-size": "cover","background-position": "center"});
            $(".left-col").css({"background-image": backgroundimg,"background-size": "cover","background-position": "center"});
        })
    </script>




	<script>
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "https://hm.baidu.com/hm.js?c41be5a0c9f014e977695f66c065b5d3";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
	</script>


<div class="scroll" id="scroll">
    <a href="#"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments"><i class="fa fa-comments-o"></i></a>
    <a href="#footer"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    $(document).ready(function() {
        if ($("#comments").length < 1) {
            $("#scroll > a:nth-child(2)").hide();
        };
    })
</script>

<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

  <script language="javascript">
    $(function() {
        $("a[title]").each(function() {
            var a = $(this);
            var title = a.attr('title');
            if (title == undefined || title == "") return;
            a.data('title', title).removeAttr('title').hover(

            function() {
                var offset = a.offset();
                $("<div id=\"anchortitlecontainer\"></div>").appendTo($("body")).html(title).css({
                    top: offset.top - a.outerHeight() - 15,
                    left: offset.left + a.outerWidth()/2 + 1
                }).fadeIn(function() {
                    var pop = $(this);
                    setTimeout(function() {
                        pop.remove();
                    }, pop.text().length * 800);
                });
            }, function() {
                $("#anchortitlecontainer").remove();
            });
        });
    });
</script>


  </div>
</body>
</html>